package uodm.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.event.dom.client.ClickEvent;

public class ListOfficesWidget extends Composite {

	private ListOfficesEntry entry;

	private static OfficeListWidgetUiBinder uiBinder = GWT
			.create(OfficeListWidgetUiBinder.class);

	interface OfficeListWidgetUiBinder extends
			UiBinder<Widget, ListOfficesWidget> {
	}

	@UiField
	FlexTable officeList;
	@UiField
	Button refreshButton;
	@UiField
	Label messageLabel;

	public ListOfficesWidget(ListOfficesEntry entry) {
		this.entry = entry;
		initWidget(uiBinder.createAndBindUi(this));
	}

	@UiHandler("refreshButton")
	void onRefreshButtonClick(ClickEvent event) {
		entry.loadOfficeList();
	}
	@UiHandler("addButton")
	void onAddButtonClick(ClickEvent event) {
		entry.redirectToAddOffice();
	}
}
